
module.exports = app => {

    return class HomeController extends app.Controller {

        /**
         * 帖子列表
         * type: 1. 最新  2. 热门
         * @returns {Promise<void>}
         */
        async list() {
            let type = this.ctx.request.query.type;
            let id = this.ctx.request.query.id;
            let pageNo = this.ctx.request.query.pageNo;
            let data = {};

            this.app.logger.info(this.ctx.request.query);
            this.app.logger.info(type, id, pageNo);

            if (type == 2){
                //热门
                data = await this.ctx.service.post.hot({ id, pageNo });
            } else if (type == 3){
                data = await this.ctx.service.post.getAnswer({ id, pageNo });
            } else{
                //最新
                data = await this.ctx.service.post.list({ id, pageNo });
            }

            this.success(data);
        }



    };
};
